package solitaire.deck;

import java.awt.Graphics;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.List;

import solitaire.core.*;


public class Pile extends DrawObject {
	
	private CardCollection _pileCards = new CardCollection();
	private int _id;
	
	public CardCollection getCards()
	{
		return _pileCards;
	}
	
	public Pile(int id, double dX, double dY ) {
		startX = dX;
        startY = dY;
        _id = id;
	}
	
	public int column()
	{
		return _id;
	}
	
	public int row()
	{
		return _pileCards.size()+1;
	}
	
	public void setLocation( double dX, double dY )
    {
        startX = dX;
        startY = dY;
    }
	
	public void drawObject( Graphics g )
    {
        g.drawRect((int)(startX - sidelength /2), 
        			(int)(startY - sidelength /2), 
        			(int)sidelength, 95 );
    }

    public boolean contains( Point2D point )
    {
        return new Rectangle2D.Double( startX - sidelength /2, 
        		startY - sidelength /2, sidelength, sidelength ).contains( point );
    }
    
    public void addCard(Card card)
    {
    	card.setPile(this);
    	setCardLocation(card);
    	_pileCards.add(card);
    }
    
    public void removeCard(Card card)
    {
    	//setCardLocation(card);
    	_pileCards.remove(card);
    }
    
    public void addTrailList(CardCollection cards)
    {
    	for(Card card : cards)
    	{
    		addCard(card);
    	}
    }
    
    public void removeTrailList(CardCollection cards)
    {
    	for(Card card : cards)
    	{
    		removeCard(card);
    	}
    }
    
    
    protected void setCardLocation(Card card)
    {
    	System.out.println("Overide this");
    }
    
    public String toString()
    {
    	return startY + " " + startX; 
    }
}